package ioStream.file.processStream.characterStream;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA
 * Description:缓冲字符输入流学习
 * User:22954
 * Date:2024-03-17
 * Time:18:43
 */
@SuppressWarnings("all")
public class BufferedReader_ {
    /*
    class BufferedReader extends Reader 缓冲字符输入流也继承输入流
    ============================================================
    private Reader in
    BufferedReader(Reader in)  包装节点流中的输入流
    ==========================================================
    close()->implClose()->in.close()  缓冲流的关闭底层调用节点流的关闭
     */
    public static void main(String[] args) {
        String filePath = "C:\\Users\\22954\\Desktop\\IDEA\\Java\\Test\\src\\test/Test3.java";
        BufferedReader bufferedReader = null;
        try {
            bufferedReader = new BufferedReader(new FileReader(filePath));
            String data = null;
            while ((data = bufferedReader.readLine()) != null) {
                System.out.println(data);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                bufferedReader.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
